package cn.mldn.microcloud.rest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.mldn.microcloud.service.IDeptService;
import cn.mldn.vo.Dept;

@RestController
public class DeptRest {
	@Resource
	private IDeptService deptService ;

	@RequestMapping("/dept/sessionId")
	public Object id(HttpServletRequest request) {
		return request.getSession().getId() ;
	}

	@ApiOperation(value="获取用户信息", notes="根据ID获取用户信息")
	@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path")
	@RequestMapping(value="/dept/get/{id}",method=RequestMethod.GET)
	public Object get(@PathVariable("id") long id) {
		return this.deptService.get(id) ;
	}


	@ApiOperation(value="添加用户信息", notes="添加用户信息")
	@ApiImplicitParam(name = "dept", value = "用户实体dept", required = true, dataType = "Dept")
	@RequestMapping(value="/dept/add",method=RequestMethod.POST)
	public Object add(@RequestBody Dept dept) {
		return this.deptService.add(dept) ;
	}

	@ApiOperation(value="获取所有用户", notes="获取所有用户")
	@RequestMapping(value="/dept/list",method=RequestMethod.GET)
	public Object list() throws InterruptedException {
		//Thread.sleep(1500L);
		return this.deptService.list() ;
	}
}
